package TestDemo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2024-03-13
 * Time: 15:37
 */
class Animal{
    public String name;
    public int age;
    public String color;

    static {
        System.out.println("Animal的静态代码块");
    }
    {
        System.out.println("Animal的实例代码块");
    }
    public Animal(String name){
        this.name = name;
        System.out.println("Animal(String)");
    }
    public void eat(){
        System.out.println(name + "正在吃粮！");
    }
}
class Dog extends Animal{
    static {
        System.out.println("Dog的静态代码块");
    }
    {
        System.out.println("Dog的实例代码块");
    }
    public Dog(String name){
        super(name);
        System.out.println("Dog的构造方法");
    }
    public void wag(){
        System.out.println(name  + "正在汪汪叫！");
    }
}

/*class Cat extends Animal{
    public void wag(){
        System.out.println(name  + "正在喵喵叫！");
    }
}*/

public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog("初一");
        System.out.println("======================");
        Dog dog2 = new Dog("十五");
        /*TestDemo1.Dog dog = new TestDemo1.Dog();
        dog.name = "初一";
        dog.age = 3;
        dog.color = "黑色";
        dog.eat();
        dog.wag();

        System.out.println("===================");

        TestDemo1.Cat cat = new TestDemo1.Cat();
        cat.name = "初五";
        cat.age = 2;
        cat.color = "白色";
        cat.eat();
        cat.wag();*/
    }
}
